
#include "core/core_error.h"

#define MSG_BEGIN(e) switch((e)) {
#define MSG_DEF(def) case core_error::def: return #def;
#define MSG_END }

std::string core_category_impl::message(int e) const {
  MSG_BEGIN(e)
      MSG_DEF(invalid_parameters)
      MSG_DEF(handle_serial_number_overflow)
      MSG_DEF(svr_id_overflow)
      MSG_DEF(load_module_failed)
      MSG_DEF(invalid_service_name)
      MSG_DEF(dup_service_name)
      MSG_DEF(service_init_failed)
      MSG_DEF(send_dest_not_exist)
      MSG_DEF(ejector_is_down)
  MSG_END
}

#undef MSG_BEGIN
#undef MSG_DEF
#undef MSG_END

const utils::error_category& core_category(void) {
  static core_category_impl inst;
  return inst;
}

utils::error_code make_error_code(core_error::core_error_t ec) {
  return utils::error_code(static_cast<int>(ec), core_category());
}

utils::error_condition make_error_condition(core_error::core_error_t ec) {
  return utils::error_condition(static_cast<int>(ec), core_category());
}

